<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <meta name="description" content=""/>
    <meta name="author" content="" />
    <title>汽车购票系统——用户注册页面</title>
    <link th:href="@{/css/registe_user.css}" rel="stylesheet">
</head>
<body>
<form class="registe" th:action="@{/customer/register}"method="post">
    <div class="registe_head"><img th:src="@{/image/logo.png}"></div>
    <div style="text-align: center;" th:if="${errorMsg} != null" id="myAlert" class="alert alert-danger" data-dismiss="alert"
         th:text="${errorMsg}">
    </div>
    <p class="rg_p1">账号登录</p>
    <table><input id="username" name="username"type="text" placeholder="请输入账号"></table>
    <table><input id="password" name="password" type="password" placeholder="请输入密码"></table>
    <table><input id="number" name="number" type="text" placeholder="请输入电话号码"></table>
    <span id="msg" style="display: none"></span>
    <button class="btn" type="submit" onClick="return check()">立即注册</button>
    <p class="rg_p2">已有账号<a th:href="@{/customer/login}">立即登录</a></p>
</form>
</body>
<script>
    function check() {
        var user = document.getElementById("user").value;
        var password = document.getElementById("password").value;
        var repassword = document.getElementById("repassword").value;
        var msg = document.getElementById("msg");
        if(user==""&&password==""){
            msg.innerHTML ="账号密码不能为空";
            msg.style.display ="block";
            return false;
        }
        if (user==""&&password!=""){
            msg.innerHTML ="账号不能为空";
            msg.style.display ="block";
            return false;
        }
        if (user!=""&&password=="") {
            msg.innerHTML ="密码不能为空";
            msg.style.display ="block";
            return false;
        }
        if (password!=repassword) {
            msg.innerHTML = "两次密码不一致";
            msg.style.display = "block";
            return false;
        }
    }
</script>
<script>
    function codefans(){
        var msg = document.getElementById("myAlert");
        msg.style.display="none";
    }
    setTimeout("codefans()",2000);
</script>
</html>
